<?php
namespace app\admin\controller;

use cmf\controller\AdminBaseController;
use think\Db;

class RechargeController extends AdminBaseController
{
  public function _initialize()
  {
  }
  
  /**用户充值记录列表*/
  public function index ()
  {
  
    $where   = [];
    $request = input('request.');
    
    if (!empty($request['uid'])) {
      $where['izy_user.uid'] = array( 'EQ', intval($request['uid']));
    }
    
    if (!empty($request['mobile'])) {
      $query_mobile = $request['mobile'];
      $where['izy_user.mobile'] = array('LIKE', "%$query_mobile%");
    }
  
    if (!empty($request['date'])) {
      $query_time = strtotime($request['date']);
      $where['izy_user_cash_order.ctime'] = array('EGT', $query_time);
    }
    
    $list = Db::connect('aizuoyou')
      ->name('user_cash_order')
      ->join('user','izy_user_cash_order.uid = izy_user.uid')
      ->where($where)
      ->field(array('izy_user.uid', 'izy_user.username', 'izy_user.truename', 'izy_user.mobile', 'izy_user_cash_order.money', 'izy_user_cash_order.ctime'))
      ->order("izy_user_cash_order.ctime DESC")
      ->paginate(10);
    
    // 获取分页显示
    $page = $list->render();
    $this->assign('list', $list);
    $this->assign('page', $page);
    // 渲染模板输出
    return $this->fetch();
  }
}